package com.example.dps;



import org.json.JSONException;
import org.json.JSONObject;

import android.database.Cursor;

public class Account {
	
	public double amount = 0;
	
	public String name;
	
	public int id;
	
	String fullName;
	String birthdate;
	String socialSecurity;
	String employer;
	String phoneNumber;
	
	String homeAddress;
	String homeCity;
	String homeState;
	String homeZip;
	
	String routeNum;
	String checkNum;
	
	
	Account(String name, String checkNum, String routeNum, int amount){
		
		this.name = name;
		this.checkNum = checkNum;
		this.routeNum = routeNum;
		this.amount = amount;
	}
	
	Account(JSONObject json){
		
		try{
			this.name = (String) json.getString("name");
			this.id = json.getInt("_id");
			this.checkNum = json.getString("checkNum");
			this.routeNum = json.getString("routeNum");
			
			this.amount = json.getDouble("amount");
			
			this.fullName = json.getString("fullName");
			this.birthdate = json.getString("birthdate");
			this.socialSecurity = json.getString("socialSecurity");
			this.employer = json.getString("employer");
			this.phoneNumber = json.getString("phoneNumber");
			
			this.homeAddress = json.getString("homeAddress");
			this.homeCity = json.getString("homeCity");
			this.homeState = json.getString("homeState");
			this.homeZip = json.getString("homeZip");
		}
		catch(JSONException e){
			e.printStackTrace();
		}
		
		
		
		
		
	}
	
	Account(Cursor accountCursor){
		
		
		
		if(accountCursor.moveToFirst()){
			
			id = accountCursor.getInt(accountCursor.getColumnIndex("_id"));
			name = accountCursor.getString(accountCursor.getColumnIndex(AccountDBHelper.COLUMN_ACCOUNT_NAME));
			
			amount = accountCursor.getInt(accountCursor.getColumnIndex(AccountDBHelper.COLUMN_ACCOUNT_AMOUNT));
			
			fullName = accountCursor.getString(accountCursor.getColumnIndex(AccountDBHelper.COLUMN_ACCOUNT_FULLNAME));
			birthdate = accountCursor.getString(accountCursor.getColumnIndex(AccountDBHelper.COLUMN_ACCOUNT_BIRTHDATE));
			socialSecurity = accountCursor.getString(accountCursor.getColumnIndex(AccountDBHelper.COLUMN_ACCOUNT_SOCIAL_SECURITY));
			employer = accountCursor.getString(accountCursor.getColumnIndex(AccountDBHelper.COLUMN_ACCOUNT_EMPLOYER));
			phoneNumber = accountCursor.getString(accountCursor.getColumnIndex(AccountDBHelper.COLUMN_ACCOUNT_PHONE_NUMBER));
			homeAddress = accountCursor.getString(accountCursor.getColumnIndex(AccountDBHelper.COLUMN_ACCOUNT_HOME_ADDRESS));
			homeCity = accountCursor.getString(accountCursor.getColumnIndex(AccountDBHelper.COLUMN_ACCOUNT_HOME_CITY));
			homeState = accountCursor.getString(accountCursor.getColumnIndex(AccountDBHelper.COLUMN_ACCOUNT_HOME_STATE));
			homeZip = accountCursor.getString(accountCursor.getColumnIndex(AccountDBHelper.COLUMN_ACCOUNT_HOME_ZIP));
			checkNum = accountCursor.getString(accountCursor.getColumnIndex(AccountDBHelper.COLUMN_ACCOUNT_CHECKNUM));
			routeNum = accountCursor.getString(accountCursor.getColumnIndex(AccountDBHelper.COLUMN_ACCOUNT_ROUTENUM));
		}

		//accountCursor.close();

		
	}
	
	Account(){
		
		
	}
	
	

}
